package br.edu.ufcg.dsc.services;

import java.util.List;

import javax.persistence.EntityTransaction;
import javax.persistence.Query;

import br.edu.ufcg.dsc.domain.Reservation;

public class ReservationService extends BaseService {

	public static void persist(Reservation r) {
		EntityTransaction tx = entity.getTransaction();
		tx.begin();
		try {
			entity.persist(r);
			tx.commit();
		} catch (Exception e) {
			e.printStackTrace();
			tx.rollback();
		}
	}
	
	@SuppressWarnings("unchecked")
	public static List<Reservation> findAllReservations() {
		Query q = entity.createQuery("SELECT r FROM br.edu.ufcg.dsc.domain.Reservation r");
		List<Reservation> r = q.getResultList();
		return r;
	}
}
